/**
 * https://leetcode-cn.com/problems/jump-game/submissions/
 * @param {number[]} nums
 * @return {boolean}
 */
 var canJump = function(nums) {
  let maxDistance = 0;    
  for (let i = 0; i < nums.length; i++) {
      if (maxDistance >= i) {
          maxDistance = Math.max(maxDistance, nums[i] + i);
      }
  }
  return maxDistance >= nums.length - 1
};
